package com.ruoyi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

/**
 * 启动程序
 * 
 * @author ruoyi
 */
import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication
{
    public static void main(String[] args)
    {
        ConfigurableApplicationContext context = SpringApplication.run(RuoYiApplication.class, args);
        Environment env = context.getEnvironment();
        String port = env.getProperty("server.port", "8080");
        String contextPath = env.getProperty("server.servlet.context-path", "/");
        String hostAddress = "localhost";

        try {
            hostAddress = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            System.err.println("无法获取本机IP地址，使用localhost作为默认值");
        }

        System.out.println("(♥◠‿◠)ﾉﾞ  项目启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                "  _____    ___   __   __\n" +
                " |  ___|  / _ \\  \\ \\ / /\n" +
                " | |_    | | | |  \\ V / \n" +
                " |  _|   | |_| |   | |  \n" +
                " |_|      \\__\\_\\   |_|  \n" +
                "                        \n" +
                "本地后端访问地址: http://" + hostAddress + ":" + port + contextPath);
    }
}